package com.zhiziai.aiproxy.constants;

import java.util.Arrays;

public enum BusinessCode {

    /**
     * 基础
     */
    SUCCESS(1000, "请求成功"),
    ERROR(1001, "请求失败"),
    NOLOGIN(1002, "未登录"),
    NOAUTHORITY(1003, "没有权限访问"),
    ERRORTOKEN(1004, "非法签名"),
    EMPTYPARAMS(1005, "请求参数为空"),
    ERRORPARAMS(1006, "请求参数错误"),
    ERRORUSERNAMEORPW(1007, "账号密码错误"),


    ;

    private final int value;
    private final String msg;

    public int getValue() {
        return this.value;
    }

    private BusinessCode(int code, String msg) {
        this.value = code;
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public static BusinessCode getByName(String name) {
        return Arrays.stream(values()).filter(item -> item.toString().equals(name)).findFirst().orElse(null);
    }
}
